<template>
	<view class="main-content">
		<MHeader>{{ state.pageName }}</MHeader>
		<scroll-view scroll-y="true" style="height: calc(100% - 80rpx)">
			<view>
				<item name="单据编号">
					<view class="input">{{state.info.Data.BillNo}}</view>
				</item>
				<item name="客户">
					<view>{{state.info.Data.F_QUQY_Customer?.Name[0].Value}}</view>
				</item>
				<item name="客户电话">
					<view>{{state.info.Data.F_QUQY_CustTelephone}}</view>
				</item>
				<item name="客户地址">
					<view>{{state.info.Data.F_QUQY_CustAddress}}</view>
				</item>
				<item name="组织">
					<view>{{state.info.Data.F_QUQY_OrgId?.Name[0].Value}}</view>
				</item>
				<item name="养殖批次">
					<view>{{state.info.Data.F_QUQY_BreedingContract?.Name[0].Value}}</view>
				</item>
				<item name="是否退药">
					<view>{{state.info.Data.F_QUQY_DrugRepercussion== '1' ? '是' : '否'}}</view>
				</item>

			</view>
			<MHeader hidTag>
				<van-icon name="cluster" color="#1989fa" style="margin-right: 10rpx" />
				兽药列表
			</MHeader>
			<view style="padding-bottom: 10rpx">
				<view class="card" v-for="(item, index) in state.info.Data.FEntity">
					<view class="card-index">{{ index + 1 }}</view>
					<item name="药物" @longpress="longpress(item, index)">
						<view>{{item.F_QUQY_Medicinal?.Name[0].Value}}</view>
					</item>
					<item name="基本单位">
						<view>{{item.F_QUQY_BaseUnit?.Name[0].Value}}</view>
					</item>
					<item name="数量">
						<view>{{item.F_QUQY_UnitPrice}}</view>
					</item>
					<item name="含税单价">
						<view style="padding-right: 35rpx;">{{item.F_QUQY_Price}}</view>
						<text class="symbol">元</text>
					</item>
					<item name="价税合计">
						<view style="padding-right: 35rpx;">{{item.F_QUQY_Amount}}</view>
						<text class="symbol">元</text>
					</item>
					<item name="仓库">
						<view>{{item.F_QUQY_VDStock?.Name[0].Value}}</view>
					</item>
					<item name="已出库数量">
						<view>{{item.F_QUQY_OutboundQty}}</view>
					</item>
				</view>
			</view>
		</scroll-view>
	</view>
	<Loading v-if="state.loading"></Loading>
</template>

<script setup>
	import moment from 'moment';
	import { reactive, getCurrentInstance, ref, watch, nextTick } from 'vue';
	import { onLoad } from '@dcloudio/uni-app';
	import { checkForm, msg } from '/utils/utils.js';
	import kdApis from '/api/modularApi/kdApi.js';
	import { next } from 'lodash-es';
	const { proxy } = getCurrentInstance();
	const state = reactive({
		info: {
			FormId: 'QUQY_BreContract',
			Data: {
				Model: {
					F_QUQY_ORGID: {
						FNumber: null
					},
					F_QUQY_FARMERS: {
						FNumber: null
					},
					F_QUQY_YWY: {
						FSTAFFNUMBER: null
					},
					F_QUQY_LIAOCAR: {
						FNUMBER: null
					},
					F_QUQY_ORGCUST: {
						FNUMBER: null
					}
				}
			}
		},
		pageName: ' ',
		loading: true
	});

	const getDetails = (Id) => {
		kdApis.formView({
			formId: 'QUQY_VeterinaryMedicineApplication',
			data: { Id }
		}).then((res) => {
			if (res) {
				state.info.Data = res
				state.loading = false
			}
		})
	}

	onLoad(async (query) => {
		if (query.Id) {
			state.pageName = '兽药申请详情'
			getDetails(query.Id)
		}
	});
</script>
<style lang="scss" scoped>
	.card {
		position: relative;
		width: calc(100% - 60rpx);
		margin: 20rpx auto;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
		border-radius: 6rpx;

		.card-index {
			position: absolute;
			display: flex;
			width: 40rpx;
			height: 40rpx;
			padding-left: 10rpx;
			font-size: 24rpx;
			background: #409eff;
			color: #fff;
			clip-path: polygon(0 0, 0 40rpx, 10rpx 40rpx, 40rpx 10rpx, 40rpx 0);
		}
	}
</style>